package com.todo.content.application.backend.controller;

import com.todo.common.common.entity.response.BizPageResponse;
import com.todo.common.common.entity.response.BizResponse;
import com.todo.content.application.backend.service.ContentInfoBackendService;
import com.todo.content.iface.backend.ContentBackendIface;
import com.todo.content.iface.backend.request.*;
import com.todo.content.iface.backend.response.ContentBaseInfoResp;
import com.todo.content.iface.backend.response.ContentDetailResp;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author azhebuxing
 * @date 2024/7/5 11:42
 * @description
 */
@RestController
@RequestMapping("/bd/content")
@Tag(name = "内容后台处理类", description = "内容后台处理类")
public class ContentBackendController implements ContentBackendIface {

    @Resource
    private ContentInfoBackendService contentInfoBackendService;


    @Override
    @Operation(summary = "根据主键id删除内容")
    @PostMapping("/removeContentById")
    public BizResponse<Boolean> removeContentById(@RequestBody RemoveContentByIdReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return contentInfoBackendService.removeContentById(req);
    }

    @Override
    @Operation(summary = "根据主键id查询内容详情")
    @PostMapping("/queryContentDetailById")
    public BizResponse<ContentDetailResp> queryContentDetailById(@RequestBody QueryContentDetailByIdReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return contentInfoBackendService.queryContentDetailById(req);
    }

    @Override
    @Operation(summary = "禁用内容")
    @PostMapping("/disableContentById")
    public BizResponse<Boolean> disableContentById(@RequestBody DisableContentByIdReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return contentInfoBackendService.disableContentById(req);
    }

    @Override
    @Operation(summary = "多条件查询内容基础信息")
    @PostMapping("/queryContentInfoByCondition")
    public BizPageResponse<ContentBaseInfoResp> queryContentInfoByCondition(@RequestBody QueryContentInfoByConditionReq req) {
        if (req == null) {
            return BizPageResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizPageResponse.paramError("参数错误");
        }
        return contentInfoBackendService.queryContentInfoByCondition(req);
    }

    @Override
    @Operation(summary = "人工检测内容是否通过")
    @PostMapping("/detectionContentById")
    public BizResponse<Boolean> detectionContentById(@RequestBody DetectionContentReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return contentInfoBackendService.detectionContentById(req);
    }
}
